package com.wanxi.education.controller.front;

import com.github.pagehelper.PageInfo;
import com.wanxi.education.common.CommonResult;
import com.wanxi.education.model.vo.advertandcertificate.ClassificationForCourseVo;
import com.wanxi.education.model.vo.advertandcertificate.ClassificationFrontVo;
import com.wanxi.education.service.ClassificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: yanguangqiong
 * @Description:
 * @Date: Created in 2021/9/24
 * @Version: 1.0
 */
@Api(tags = "前端证书分类管理")
@RestController
@RequestMapping("/user/front/classification")
public class ClassificationFrontController {
    @Autowired
    private ClassificationService classificationService;
    /*
    * 用作导航查找父id为0的分类名，前6个根据权重排
    * */
    @GetMapping("/findNavigation")
    @ApiOperation("证书分类导航列表")
    public CommonResult<PageInfo<ClassificationFrontVo>> findNavigation() {
        PageInfo<ClassificationFrontVo> pageInfo = classificationService.findNavigation();
        return CommonResult.success(pageInfo);
    }

    @GetMapping("/findAll")
    @ApiOperation("点击更多的时候")
//    查找父id为0的分类
    public CommonResult<List<ClassificationForCourseVo>> findAll() {
        List<ClassificationForCourseVo>  list=classificationService.findAll();
        return CommonResult.success(list);
    }

    @GetMapping("/findByPid")
    @ApiOperation("点击分类时的子分类")
//    查找父id为0的分类
    public CommonResult<List<ClassificationFrontVo>> findByPid(@RequestParam("pid") Long pid) {
        List<ClassificationFrontVo>  list=classificationService.findByPid(pid);
        return CommonResult.success(list);
    }

}
